$(function(){
    //头部下拉
    $('.dropdown').hover(function(){
        $(this).addClass('active')
    },function(){
        $(this).removeClass('active')
    });

    $('.rnav li a').click(function(){
        if($(this).siblings('.rnav-list').is(':visible')){
            $(this).removeClass('active').siblings('.rnav-list').slideUp();
        }else{
            $(this).addClass('active').siblings('.rnav-list').slideDown();
            $(this).parent().siblings().children('a').removeClass('active').siblings('.rnav-list').slideUp();
        }
    });

    $('.home-qyzx-rlist li').hover(function(){
        $(this).addClass('active').siblings().removeClass('active');
    });
    // $('.home-rmzt-rlist li').hover(function(){
    //     $(this).addClass('active').siblings().removeClass('active');
    // });
    $('.juhe-phb-list li').hover(function(){
        $(this).addClass('active').siblings().removeClass('active');
    });
    
    $('.rphb-box-list li').hover(function(){
        $(this).addClass('active').siblings().removeClass('active');
    });

    $('.nav5 .more').click(function(){
        if($(this).siblings('.more-box').is(':hidden')){
            $(this).addClass('active').siblings('.more-box').slideDown();
        }else{
            $(this).removeClass('active').siblings('.more-box').slideUp(); 
        }
    });

    $('.zt-cyxm-list li').hover(function(){
        $(this).addClass('active').siblings().removeClass('active');
    },function(){
        $(this).removeClass('active');
    });

    // $('.company-list-left-tit a,.nav-cszx').click(function(){
    //     if($('.company-list-top').is(':hidden')){
    //         $(this).addClass('active');
    //         $('.company-list-top').slideDown()
    //     }else{
    //         $(this).removeClass('active');
    //         $('.company-list-top').slideUp()
    //     }
    // });

    (function(){
        $home_cates = $('#home-cates');
        $open = $home_cates.find('.open');
        $close = $home_cates.find('.close');
        $ul = $home_cates.find('ul');
        $open.on('click',function(){
            $open.hide()
            $close.show();
            $ul.animate({height:'732px'})
        })
        $close.on('click',function(){
            $open.show()
            $close.hide();
            $ul.animate({height:'456px'})
        })
    })();

    //swiper
    (function(){
        var swiper = new Swiper('.home-banner-swiper',{
            loop:true,
            autoplay:3000,
            pagination:'.home-banner-swiper .swiper-pagination',
            paginationClickable:true
        });
        $('.home-banner-swiper .swiper-button-prev').on('click',function(){
            swiper.swipePrev()
        });
        $('.home-banner-swiper .swiper-button-next').on('click',function(){
            swiper.swipeNext()
        });
    })();

    (function(){
        var swiper = new Swiper('.home-ppsb-swiper .swiper-container',{
            loop:true,
            autoplay:3000,
            slidesPerView:5
        });
        $('.home-ppsb-swiper .swiper-button-prev').on('click',function(){
            swiper.swipePrev()
        });
        $('.home-ppsb-swiper .swiper-button-next').on('click',function(){
            swiper.swipeNext()
        });
    })();

    (function(){
        var swiper = new Swiper('.home-pptj-swiper',{
            loop:true,
            autoplay:3000,
            pagination:'.home-pptj-swiper .swiper-pagination',
            paginationClickable:true
        });
        $('.home-pptj-swiper .swiper-button-prev').on('click',function(){
            swiper.swipePrev()
        });
        $('.home-pptj-swiper .swiper-button-next').on('click',function(){
            swiper.swipeNext()
        });
    })();

    (function(){
        var swiper = new Swiper('.home-ppjj-swiper .swiper-container',{
            loop:true,
            autoplay:3000,
            pagination:'.home-ppjj-swiper .swiper-pagination',
            paginationClickable:true
        })
    })();

    (function(){
        var swiper = new Swiper('.home-rmzt-swiper',{
            loop:true,
            autoplay:3000
        });
        $('.home-rmzt-swiper .swiper-button-prev').on('click',function(){
            swiper.swipePrev()
        });
        $('.home-rmzt-swiper .swiper-button-next').on('click',function(){
            swiper.swipeNext()
        });
    })();

    (function(){
        var swiper = new Swiper('.company-zsxm-swiper .swiper-container',{
            loop:true,
            autoplay:3000,
            slidesPerView:5
        });
        $('.company-zsxm-swiper .swiper-button-prev').on('click',function(){
            swiper.swipePrev()
        });
        $('.company-zsxm-swiper .swiper-button-next').on('click',function(){
            swiper.swipeNext()
        });
    })();

    (function(){
        var swiper = new Swiper('.company-cbdn-swiper',{
            loop:true,
            autoplay:3000,
            pagination:'.company-cbdn-swiper .swiper-pagination',
            paginationClickable:true
        });
    })();

    (function(){
        var swiper = new Swiper('.juhe-hyrd-swiper .swiper-container',{
            loop:true,
            autoplay:3000,
            pagination:'.juhe-hyrd-swiper .swiper-pagination',
            paginationClickable:true
        });
    })();

    (function(){
        var swiper = new Swiper('.rbox-swiper',{
            autoplay:3000,
            pagination:'.rbox-swiper .swiper-pagination',
            paginationClickable:true,
            onSwiperCreated:function(){
                $('.rbox-swiper .swiper-pagination span').each(function(i){
                    $(this).html(i+1);
                });
            }
        });
    })();

    (function(){
        var swiper = new Swiper('.news-hottopic-left-swiper',{
            loop:true,
            autoplay:3000,
        });
        $('.news-hottopic-left-swiper .swiper-button-prev').on('click',function(){
            swiper.swipePrev()
        });
        $('.news-hottopic-left-swiper .swiper-button-next').on('click',function(){
            swiper.swipeNext()
        });
    })();

    (function(){
        $('.pic-cont-swiper .swiper-pagination span').eq(1).html($('.pic-cont-swiper .swiper-slide').length);
        var swiper = new Swiper('.pic-cont-swiper',{
            loop:true,
            autoplay:false,
            onSwiperCreated:function(swiper){
                $('.pic-cont-swiper .swiper-pagination span').eq(0).html(swiper.activeIndex)
            },
            onSlideChangeEnd:function(swiper){
                var idx = swiper.activeIndex==5 ? 1 : swiper.activeIndex;
                $('.pic-cont-swiper .swiper-pagination span').eq(0).html(idx);
            }
        });
        $('.pic-cont-swiper .swiper-button-prev').on('click',function(){
            swiper.swipePrev()
        });
        $('.pic-cont-swiper .swiper-button-next').on('click',function(){
            swiper.swipeNext()
        });
    })();

    (function(){
        var swiper = new Swiper('.rbox-sl-item-cont-swiper .swiper-container',{
            loop:true,
            autoplay:3000,
            pagination:'.rbox-sl-item-cont-swiper .swiper-pagination',
            paginationClickable:true
        });
        $('.rbox-sl-item-cont-swiper .swiper-button-prev').on('click',function(){
            swiper.swipePrev()
        });
        $('.rbox-sl-item-cont-swiper .swiper-button-next').on('click',function(){
            swiper.swipeNext()
        });
    })();

    (function(){
        var swiper = new Swiper('.zt-banner-swiper',{
            loop:true,
            autoplay:3000,
            pagination:'.zt-banner-swiper .swiper-pagination',
            paginationClickable:true
        });
    })();

    (function(){
        var swiper = new Swiper('.zt-hyzx-swiper',{
            autoplay:3000,
            pagination:'.zt-hyzx-swiper .swiper-pagination',
            paginationClickable:true,
            onSwiperCreated:function(){
                $('.zt-hyzx-swiper .swiper-pagination span').each(function(i){
                    $(this).html(i+1);
                });
            }
        });
    })();

    (function(){
        var swiper = new Swiper('.company-gdxw-swiper',{
            loop:true,
            autoplay:3000,
            pagination:'.company-gdxw-swiper .swiper-pagination',
            paginationClickable:true,
        });
    })()

    //无缝滚动
    $('.home-cywd-marquee').kxbdMarquee({'direction':'up','scrollDelay':40});
    $('.home-interest-marquee').kxbdMarquee({'direction':'left','scrollDelay':20});
    $('.juhe-jmdt-marquee').kxbdMarquee({'direction':'up','scrollDelay':40});

    //切换卡
    $('.home-pptj-slide').slide({effect:'left'})
    $('.home-pptj-slide2').slide({effect:'left'})
    $('.home-mqzs-slide').slide({effect:'left'})
    $('.home-friendly').slide({effect:'fade'});
    $('.rbox-slide').slide({effect:'left'});
    $(".juhe-hynews-notice-slide").slide({mainCell:".bd ul",autoPage:true,effect:"topLoop",autoPlay:true,vis:1,interTime:1500});
    $('.juhe-tjrmyx-slide').slide({effect:'left'});
    $('.juhe-wdzt').slide({effect:'left'});
    $('.juhe-pprzbq').slide({effect:'left'});
    $('.scate-pic-slide').slide({effect:'fade'});
    $('.scate-mqzq-list-slide').slide({effect:'left'});
    $(".company-mqtj-right-slide").slide();
    $(".company-cpzs-slide").slide({titCell:".hd ul",mainCell:".bd ul",autoPage:true,effect:"left",scroll:1,vis:9,trigger:"click"});
    $(".company-list-right-slide").slide();
    $(".news-jrp-pptj-slide").slide({autoPlay:true,interTime:5000,});
    $(".item-cont-left-slide").slide({effect: 'left'});

    //弹出层
    $('#lyb_popup').popup({background:false,transition: 'all 0.3s'});
    $('#detail_popup').popup({background:false,transition: 'all 0.3s'});
    $('#kj_popup').popup({background:false,type:'tooltip',offsetleft:-120});

    

    
    ;(function(){
        var dtshowClass = $('.news-hydt-select-box>span');
        var dtlistContainer = $('.news-hydt-select-box');
        var dtcloseContainer = $('.news-hydt-select-box>i');
        var dtshowUl = $('.news-hydt-select-box>ul');
        dtshowUl.hide();
        var s = 0;

        var gdshowClass = $('.news-jrgd-select-box>span');
        var gdlistContainer = $('.news-jrgd-select-box');
        var gdcloseContainer = $('.news-jrgd-select-box>i');
        var gdshowUl = $('.news-jrgd-select-box>ul');
        gdshowUl.hide();
        var t = 0;
        // 今日动态
        dtshowClass.click(function(){
            if(s == 0){
            dtlistContainer.addClass('news-hydt-class-show').removeClass('news-hydt-class-close');
            dtshowClass.text('>');
            dtcloseContainer.width(40);
            dtcloseContainer.text('收起');
            dtshowUl.show();
            s = 1;
            } else {
            dtlistContainer.removeClass('news-hydt-class-show').addClass('news-hydt-class-close');
            dtshowClass.text('<');
            dtcloseContainer.text('行业切换');
            dtcloseContainer.width(74);

            dtshowUl.hide();
            s = 0;
            }
            if(dtcloseContainer.text()=='收起'){
            dtcloseContainer.click(function(){
                dtlistContainer.removeClass('news-hydt-class-show').addClass('news-hydt-class-close');
                dtshowClass.text('<');
                dtcloseContainer.text('行业切换');
                dtcloseContainer.width(74);
        
                dtshowUl.hide();
                s = 0;
            })
            }
        })

        // 今日各地
        gdshowClass.click(function(){
            if(t == 0){
            gdlistContainer.addClass('news-hydt-class-show').removeClass('news-hydt-class-close');
            gdshowClass.text('>');
            gdcloseContainer.width(40);
            gdcloseContainer.text('收起');
            gdshowUl.show();
            t = 1;
            } else {
            gdlistContainer.removeClass('news-hydt-class-show').addClass('news-hydt-class-close');
            gdshowClass.text('<');
            gdcloseContainer.text('地区切换');
            gdcloseContainer.width(74);

            gdshowUl.hide();
            t = 0;
            }
            if(gdcloseContainer.text()=='收起'){
            gdcloseContainer.click(function(){
                gdlistContainer.removeClass('news-hydt-class-show').addClass('news-hydt-class-close');
                gdshowClass.text('<');
                gdcloseContainer.text('地区切换');
                gdcloseContainer.width(74);
        
                gdshowUl.hide();
                t = 0;
            })
            }
        })
    })();

    ;(function(){
        // 左侧固定浮动
        $('.hotpage-list-nav .returntop').hover(function(){
            $(this).find("span").animate({left:"-80px"});
        },function(){
            $(this).find("span").animate({left:"0px"});
        });

        // 返回顶部
        $(".returntop").click(function(){
            $('html,body').animate({scrollTop: '0px'}, 300);
        });

        //话题-列表 显示全部
        $('.hotpage-item').each(function(){
            var $con = $(this).find('.hotpage-list-con');
            var $more = $(this).find('.hotpage-list-more a');
            $more.attr('sta',0);
            (function($c,$m){
                var h = $c.height();
                $m.attr('h',h);
                if(h>100) {
                    $c.height(100);
                    $m.click(function(){
                        var sta = parseInt($m.attr('sta'));
                        if(!sta){
                            $c.height(h);
                            $more.attr('sta',1);
                            $m.html('收起');
                        }else{
                            $c.height(100)
                            $more.attr('sta',0);
                            $m.html('显示全部');
                        }
                    });
                }else{
                    $m.click(function(){
                        var sta = parseInt($m.attr('sta'));
                        if(!sta){
                            $more.attr('sta',1);
                            $m.html('收起');
                        }else{
                            $more.attr('sta',0);
                            $m.html('显示全部');
                        }
                    })
                }
            })($con,$more);
        });
        
        // hot详情专题介绍
        $(".hot-intro-banner").hover(function(){
            $(this).find("p").animate({bottom:"0px"});
        },function(){
            $(this).find("p").animate({bottom:"-36px"});
        });
    })()

});